package com.hisan.freeride.common.alertwindow;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.Animation;

import com.hisan.freeride.R;
import com.hisan.freeride.common.event.DataSynEvent;
import com.hisan.freeride.common.view.ReservationFlowLayout;
import com.hisan.freeride.home.model.Reservation;


import org.greenrobot.eventbus.EventBus;

import java.util.List;

/**
 * 创建时间 : 2017/7/3
 * 创建人：yangyingqi
 * 公司：嘉善和盛网络有限公司
 * 备注：预约标签弹窗
 */
public class ScalePopup extends BasePopupWindow implements View.OnClickListener {


    private View popupView;



    public ScalePopup(Activity context,List<Reservation.TagsBean>datas) {
        super(context);
        bindEvent(context,datas);
    }

    @Override
    protected View getClickToDismissView() {
        return popupView.findViewById(R.id.click_to_dismiss);
    }

    @Override
    public View getPopupView() {
        popupView= LayoutInflater.from(mContext).inflate(R.layout.reservation_remarks,null);
        return popupView;
    }

    @Override
    public View getAnimaView() {
        return popupView.findViewById(R.id.popup_anima);
    }

    private void bindEvent(Activity context, List<Reservation.TagsBean> datas) {
        if (popupView!=null){
            popupView.findViewById(R.id.cancel).setOnClickListener(this);
            popupView.findViewById(R.id.ok).setOnClickListener(this);
            popupView.findViewById(R.id.popup_view_cont).setOnClickListener(this);
            popupView.findViewById(R.id.select_xy).setOnClickListener(this);
            ReservationFlowLayout flowLayout = (ReservationFlowLayout) popupView.findViewById(R.id.flowlayout);
            //添加数据
            flowLayout.addTags(context,datas);
            //设置是否单选
            flowLayout.setRadio(false);
        }

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.cancel:
                EventBus.getDefault().post(new DataSynEvent(2));
                break;
            case R.id.ok:
                EventBus.getDefault().post(new DataSynEvent(3));
                break;
            case R.id.popup_view_cont:
                dismiss();
                break;
            case R.id.select_xy:
                EventBus.getDefault().post(new DataSynEvent(4));
                break;
            default:
                break;
        }

    }
}
